home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / x11 / strategy / xpat2-1.000 / xpat2-1 / xpat2-1.04 / src / Xv-events.c < prev    next >
C/C++ Source or Header  |  1995-01-23  |  3KB  |  105 lines

  1. /*****************************************************************************/
  2. /*                                         */
  3. /*                                         */
  4. /*    X patience version 2 -- module Xv-events.c                 */
  5. /*                                         */
  6. /*    event handlers for the Xview interface                     */
  7. /*    written by Brandon S. Allbery                         */
  8. /*    based on code by Heiko Eissfeldt and Michael Bischoff             */
  9. /*    see COPYRIGHT.xpat2 for Copyright details                 */
  10. /*                                         */
  11. /*                                         */
  12. /*****************************************************************************/
  13.  
  14. #ifdef useXview
  15.  
  16. #include "X-pat.h"
  17.  
  18. void
  19. Force_Resize(XSize_t w, XSize_t h)
  20. {
  21.     xv_set(canvas,
  22.        XV_HEIGHT, h + 2,
  23.        XV_WIDTH, w + 2,
  24.        0);
  25.     frame_pack_all(mainwindow);
  26. }
  27.  
  28. void
  29. table_events(Xv_Window w, Event *ev)
  30. {
  31.     switch (event_xevent_type(ev))
  32.     {
  33.     case KeyPress:
  34.     key_press(&event_xevent(ev)->xkey);
  35.     break;
  36.     case MotionNotify:
  37.     mouse_motion(&event_xevent(ev)->xmotion);
  38.     break;
  39.     case ButtonRelease:
  40.     button_release(&event_xevent(ev)->xbutton);
  41.     break;
  42.     case ButtonPress:
  43.     bp_event = ev;        /* forwarded to X-events:menu_show() */
  44.     button_press(&event_xevent(ev)->xbutton);
  45.     break;
  46.     }
  47. }
  48.  
  49. void
  50. table_resize(Canvas c, int w, int h)
  51. {
  52.     resize_event(w, h);
  53. }
  54.  
  55. void
  56. table_repaint(Canvas c, Xv_Window w, Rectlist *rl)
  57. {
  58.     XExposeEvent ev;        /* forged from whole cloth... */
  59.     struct rectnode *r;
  60.  
  61.     for (r = rl->rl_head; r; r = (r == rl->rl_tail? 0: r->rn_next))
  62.     {
  63.     ev.y = rl->rl_y + r->rn_rect.r_top;
  64.     ev.x = rl->rl_x + r->rn_rect.r_left;
  65.     ev.height = r->rn_rect.r_height;
  66.     ev.width = r->rn_rect.r_width;
  67.     ev.count = (r != rl->rl_tail);
  68.     redraw_table(&ev);
  69.     }
  70. }
  71.  
  72. /*
  73.  * XView lacks a function to match the sizes of components of a frame, so we
  74.  * fake it.
  75.  *
  76.  * NB: this doesn't work, because WIN_FIT_WIDTH changes XV_WIDTH permanently.
  77.  * (In effect, it becomes a hidden extension to the window it affects, and
  78.  * subsequent calls appear to be additive.)
  79.  */
  80.  
  81. void
  82. frame_pack_all(Frame frame)
  83. {
  84.     Xv_Window win;
  85.     int n, w, maxw;
  86.  
  87.     maxw = 0;
  88.     /* I think 1 is the footer. */
  89.     for (n = 2; (win = (Xv_Window) xv_get(frame, FRAME_NTH_SUBWINDOW, n)); n++)
  90.     {
  91.     window_fit(win);
  92.     if ((w = xv_get(win, XV_WIDTH)) > maxw)
  93.         maxw = w;
  94.     }
  95. #if 0
  96.     for (n = 2; (win = (Xv_Window) xv_get(frame, FRAME_NTH_SUBWINDOW, n)); n++)
  97.     xv_set(win, WIN_FIT_WIDTH, maxw - xv_get(win, XV_WIDTH), 0);
  98. #endif
  99.     for (n = 2; (win = (Xv_Window) xv_get(frame, FRAME_NTH_SUBWINDOW, n)); n++)
  100.     xv_set(win, XV_WIDTH, maxw, 0);
  101.     window_fit(frame);
  102. }
  103.  
  104. #endif
  105.